{extend name="layout/layout" /}

{block name="content"}

<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-col-md9 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                <div class="layui-col-md9 layui-col-xs7">

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="required">*</span>活动名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="name" maxlength="20" lay-verify="name" placeholder="" autocomplete="off" value="{$info.name ?: ''}">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md3 layui-col-xs5 layui-form-item" style="margin-left: 110px;">
                    <div id="upload-image">
                        <div class="layui-upload-list thumbBox mag0 magt3" id="upload-btn" data-multi="false">
                            <input type="hidden" class="layui-input" name="img_url" value="{$info.img_url ?: ''}">
                            <img class="layui-upload-img thumbImg" src="{$info.img_url ?: ''}">
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <hr>
            <label class="layui-form-label"></span>新人奖励 </label>
            <hr>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>优惠券</label>
            <div class="layui-input-block">
                <select  name="member_coupon_id" lay-verify="required">
                    <option value=""></option>
                    {foreach $coupon as $v}
                    <option value="{$v.id ?: ''}" {if $info.member_coupon_id == $v.id} selected {/if}>{$v.name ?: ''}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <hr>
            <label class="layui-form-label"></span>推荐人奖励 </label>
            <hr>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="required">*</span>优惠券</label>
            <div class="layui-input-block">
                <select  name="invitation_coupon_id" lay-verify="required">
                    <option value=""></option>
                    {foreach $coupon as $v}
                    <option value="{$v.id ?: ''}" {if $info.invitation_coupon_id == $v.id} selected {/if}>{$v.name ?: ''}</option>
                    {/foreach}
                </select>
            </div>
        </div>


        <div class="payment-rule">
            <div class="payment-rule-group">
                {foreach name="info.invitation_rules" item="rule" key="rulekey"}
                <div class="layui-form-item layui-form-text rule-group">
                    <div class="layui-inline">
                        <label class="layui-form-label"><span class="required">*</span>奖励积分</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input vip_cost" name="invitation[{$rulekey ?: ''}]" maxlength="10" autocomplete="off" value="{$rule.invitation ?: ''}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" ><span class="required">*</span>邀请数量</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input vip_time" name="member[{$rulekey ?: ''}]" maxlength="10" autocomplete="off" value="{$rule.member ?: ''}">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn layui-btn-danger delRule-btn"><i class="layui-icon layui-icon-delete"></i></button>
                        </div>
                    </div>
                </div>
                {/foreach}
            </div>
            <div class="layui-form-item layui-form-text">
                <div class="layui-inline">
                    <label class="layui-form-label"></label>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn layui-btn-normal addRule-btn"><i class="layui-icon"></i>新增费用标准</button>
                    </div>
                </div>
            </div>
        </div>

        <input type="hidden" name="id" value="">

        <div class="layui-form-item layui-row layui-col-xs12" >
            <div class="layui-input-block">
                <div class="layui-footer" style="height: 80px;">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>
<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
<!--操作-->
<script type="text/html" id="handleBar">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</a>
</script>

<input type="hidden" class="datalist_url" value="{:url('admin/promotion/index')}">
<input type="hidden" class="add_url" value="{:url('admin/promotion/add')}">
<input type="hidden" class="edit_url" value="{:url('admin/promotion/edit')}">
<input type="hidden" class="delete_url" value="{:url('admin/promotion/delete')}">
{/block}

{block name="pagescript"}
<script>
    var DELETE_URL = "{:url('admin/product/delete')}";
</script>
<script src="__STATIC__/admin/js/qiniu/plupload.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniu.js" type="text/javascript"></script>
<script src="__STATIC__/admin/js/qiniu/qiniuConfig.js" type="text/javascript"></script>

<script src="__STATIC__/admin/pages/js/uploadfile.js" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/invitation.js" type="text/javascript"></script>
{/block}